<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <title>51问医生</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    {{--<link rel="shortcut icon" href="/Public/mobile/favicon.ico" type="image/x-icon" />--}}
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-status-bar-style" content="yes"/>
    <script src="{{url('/js/jquery.min.js')}}" type="text/javascript"></script>
    <link rel="stylesheet" href="{{url('new/css/common.css')}}" />

    <!-- Noty 提示框的js集成 -->
    <script src="{{ url('vendor/noty-2.2.9/packaged/jquery.noty.packaged.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/themes/bootstrap.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/options.js') }}"></script>

    <script src="{{url('new/js/doctor_list.js')}}"></script>
    {{--<script src="http://mcdn.anxinyisheng.com/Public/mobile/js/lib_5d2f194.js"></script>--}}
    {{--<script src="http://mcdn.anxinyisheng.com/Public/mobile/js/app_7282afb.js"></script>--}}
    <link rel="stylesheet" href="{{url('new/css/ask.css')}}" />
</head>
<body>
<div class="doctor">
    <div class="docInfo-wrapper ax-boxshadow" style="position: relative">
        <div class="icon-cover" style="position: absolute">
            <img class='doctor-icon' src="@if($userinfo){{route('Api.Image.Show',['id'=>$userinfo->portrait_id])}}@else{{route('Api.Image.Show',['id'=>0])}}@endif" ></div>
        {{--<img class='doctor-icon' src="http://mcdn.anxinyisheng.com/Public/wxyd/common/img/head_icon_c766c55.png" ></div>--}}
        <div class="doc-info-box" style="padding-left: 23%;padding-bottom: 5%;">
            <p class="name">@if($userinfo){{$userinfo->realname}}@endif
                <span></span></p>
            <p class="hospital" style="color:#cc3f65;">问题：</p>
            <p class="position">@if($question){{$question->question}}@endif</p></div>
    </div>
    <div class="ask">
        <div class="ask-input">
            <textarea id="question" placeholder="请回答用户的提问"></textarea>
        </div>
        <div class="payBtn ax-bareBtn ">
            <div class="btn">
                <button class="start-chat" id="btn_send">
                    <span></span>
                    <span class="start-chat-text">回答</span>
                </button>
            </div>
        </div>
        <div class="ax-flexBox  ask-tip">
            <svg>
                <use xlink:href="#exclamation"></use>
            </svg>
            <span>您的回答将被展示，以帮助更多患者</span></div>
    </div>
</div>
<script>
    $(function(){
        $(document).on('click','#btn_send',function(){
            var question = $('#question').val();
            if(question==''){
                noty({type:'error',text:'您还未输入回答内容哦！',timeout:800});
            }
            $.ajax({
                url:'{{route('Api.Doctor.answerQuestion')}}',
                type:'post',
                dataType:'json',
                data:{
                    q_id:'{{$question->id}}',
                    answer:question
                },
                success:function(obj){
                    if(obj.level=='success'){
                        noty({text:obj.message,type:obj.level,timeout:800,
                            callback:{
                                afterClose:function(){
                                    window.location.href='{{route('M.Doctor.myQuestions')}}';
                                }
                            }
                        });
                    }
                },
                error:function(obj){
                    var dataJson = obj.responseJSON;
                    noty({type:dataJson.level,text:dataJson.message,timeout:600});
                }
            });
        });
    });
</script>
</body>
</html>